#pragma once

#include <vector>

namespace solution_080
{

class Solution
{
public:
    int removeDuplicates(std::vector<int>& nums)
    {
        if (nums.size() <= 2)
            return nums.size();
        int dup = 0;
        for (int i = 2; i < (int)nums.size(); ++i) {
            if (nums.at(i) == nums.at(i - 2 - dup))
                ++dup;
            else if (dup > 0)
                nums.at(i - dup) = nums.at(i);

        }
        return nums.size() - dup;
    }
};

}  /* namespace solution_080 */
